﻿package mortal.game.view.guildNew.info
{
    import com.gengine.utils.*;
    import com.mui.controls.*;
    import extend.language.*;
    import flash.events.*;
    import mortal.common.global.*;
    import mortal.component.gconst.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.guildNew.data.*;
    import mortal.mvc.core.*;

    public class GuildNewInfoBtnCell2 extends GSprite
    {
        protected var _btn:GLoadedButton;
        protected var _enterBtn:GLoadedButton;
        protected var _openTime:GTextFiled;
        private var _infoObj:Object;

        public function GuildNewInfoBtnCell2()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._btn = UIFactory.gLoadedButton(ImagesConst.GuildNInfoBossBtn_upSkin, 0, 0, 128, 105, this);
            this._btn.label = "";
            this._enterBtn = UIFactory.gLoadedButton(ImagesConst.GuildNInfoOpenBtn_upSkin, 16, 102, 97, 29, this);
            this._enterBtn.label = "";
            this._openTime = UIFactory.gTextField("" + Language.getString(71459), 1, 100, 128, 25, this, GlobalStyle.textFormatLv.center());
            this._openTime.visible = false;
            this._enterBtn.visible = false;
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._btn = null;
            this._enterBtn = null;
            this._openTime = null;
            return;
        }// end function

        public function updateInfo(param1:Object) : void
        {
            var _loc_3:Boolean = false;
            this._infoObj = param1;
            if (isDisposed || param1 == null)
            {
                return;
            }
            this._btn = UIFactory.gLoadedButton(param1.skin, 0, 0, 128, 105, this);
            this._btn.label = "";
            this._btn.configEventListener(MouseEvent.CLICK, this.onCkHd);
            var _loc_2:* = param1.info;
            if (_loc_2.hasOwnProperty("mod"))
            {
                if (_loc_2.mod == "btn")
                {
                    this._enterBtn = UIFactory.gLoadedButton(_loc_2.btnSkin, 16, 102, 97, 29, this);
                    this._enterBtn.configEventListener(MouseEvent.CLICK, this.onCkHd);
                    this._openTime.visible = false;
                    this._enterBtn.visible = true;
                    if (_loc_2.hasOwnProperty("gift"))
                    {
                        _loc_3 = Boolean(_loc_2.enable);
                        this._enterBtn.enabled = _loc_3;
                        if (_loc_3)
                        {
                            if (this._btn.hasEventListener(MouseEvent.CLICK) == false)
                            {
                                this._btn.configEventListener(MouseEvent.CLICK, this.onCkHd);
                            }
                            this._enterBtn.filters = null;
                            EffectManager.glowFilterReg(this._enterBtn);
                        }
                        else
                        {
                            this._btn.removeEventListener(MouseEvent.CLICK, this.onCkHd);
                            this._enterBtn.filters = [FilterConst.colorFilter2];
                            EffectManager.glowFilterUnReg(this._enterBtn);
                        }
                        this._btn.toolTipData = "" + _loc_2.tip;
                        this._enterBtn.toolTipData = "" + _loc_2.tip;
                    }
                }
                else if (_loc_2.mod == "txt")
                {
                    this._openTime.visible = true;
                    this._enterBtn.visible = false;
                    this._openTime.htmlText = HTMLUtil.addColor(_loc_2.txt, _loc_2.color);
                }
            }
            return;
        }// end function

        private function onCkHd(event:MouseEvent) : void
        {
            Dispatcher.dispatchEvent(new DataEvent(GuildNewLocalEvent.GuildNewInfoOper, this._infoObj));
            return;
        }// end function

    }
}
